package com.hqu.environment.controller.admin;

import com.hqu.environment.dao.EquipmentDao;
import com.hqu.environment.dao.FarmDao;
import com.hqu.environment.dao.MonitorPlanDao;
import com.hqu.environment.dao.UserDao;
import com.hqu.environment.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description: 主页Controller
 * @Date: 2019/04/30 15:40
 * @Author: 邓勇嘉
 **/
@Controller
@RequestMapping("admin/main")
public class MainController {

    @Autowired
    UserDao userDao;
    @Autowired
    FarmDao farmDao;
    @Autowired
    MonitorPlanDao monitorPlanDao;
    @Autowired
    EquipmentDao equipmentDao;

    @RequestMapping("/index")
    @ResponseBody
    public Result index() {
        Integer allUserCount=userDao.selectAllCount();
        Integer applyCount= userDao.selectApplyCount();
        Integer farmCount=farmDao.selectFarmCount();
        Integer equipmentCount=equipmentDao.selectEquipmentCount();
        Integer planCount=monitorPlanDao.selectPlanCount();

        return Result.success()
                .add("allUserCount",allUserCount)
                .add("applyCount",applyCount)
                .add("farmCount",farmCount)
                .add("equipmentCount",equipmentCount)
                .add("planCount",planCount);
    }

}
